package com.sumu.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.android.volley.toolbox.NetworkImageView;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.sumu.baidunuomi.R;
import com.sumu.bean.Category;
import com.sumu.utils.VolleyHelper;

public class CategoryAdapter extends MeAdapter<Category> {

	public CategoryAdapter(List<Category> list, Context context) {
		super(list, context);
	}

	@Override
	public View createView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		if(convertView == null){
			convertView = inflater.inflate(R.layout.item_category_layout, parent, false);
			holder = new ViewHolder();
			ViewUtils.inject(holder, convertView);
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder) convertView.getTag();
			
		}
		holder.imageView.setImageUrl(list.get(position).getCategory_picurl(), VolleyHelper.getIntstance().getImageLoader());
		holder.textView_category.setText(list.get(position).getCategory_name());
		return convertView;
	}
	public static class ViewHolder{
		@ViewInject(R.id.icon_category)
		private NetworkImageView imageView;
		@ViewInject(R.id.textView_category)
		private TextView textView_category;
	}

}
